package day02_oop_code.com.itheima.d10_interface_demo;


import java.util.ArrayList;

public class ClassDataImpl1 implements ClassData{
    private ArrayList<Student> students;
    public ClassDataImpl1(ArrayList<Student> students){
        this.students = students;
    }

    @Override
    public void printAllStudentInfo() {
        System.out.println("ClassDataImpl1.printAllStudentInfo");
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            System.out.println("student.toString() = " + student.toString());
        }
    }

    @Override
    public void printAllStudentAverageScore() {
        System.out.println("ClassDataImpl1.printAllStudentAverageScore");
        double allScore = 0;
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            allScore += s.getScore();
        }
        System.out.println("平均分：" + allScore / students.size());
    }
}
